#ifndef CENTRALTABBAR_H
#define CENTRALTABBAR_H

#include "CTabBar.h"

class CentralTabBar : public CTabBar {
    Q_OBJECT

    Q_PROPERTY(QMargins dragOffset READ dragOffset WRITE setDragOffset NOTIFY dragOffsetChanged)
public:
    explicit CentralTabBar(QWidget *parent = nullptr);
    ~CentralTabBar() = default;

public:
    QMargins dragOffset() const;
    void setDragOffset(const QMargins &dragOffset);

protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;

    void leaveEvent(QEvent *event) override;

protected:
    QPoint lastPressPos;
    QPoint lastLeftBtnPos;
    QPoint lastRightBtnPos;
    QRect lastTabRect;

    QWidget *lastLeftBtn;
    QWidget *lastRightBtn;

    bool m_readyDrag;
    QMargins m_dragOffset;

    QPixmap lastTabShot() const;

signals:
    void dragStarted(int index, const QPoint &pos, const QPixmap &pixmap);

    void dragOffsetChanged();
};

#endif // CENTRALTABBAR_H
